Skip to content

fix: Rework packet loss metric tests to work with UTP 2.0 [MTT-4535]#2174

Merged
simon-lemay-unity merged 4 commits intodevelopfrom
fix/packet-loss-test
Sep 6, 2022
Merged

fix: Rework packet loss metric tests to work with UTP 2.0 [MTT-4535]#2174
simon-lemay-unity merged 4 commits intodevelopfrom
fix/packet-loss-test

Conversation

@simon-lemay-unity
Copy link
Copy Markdown
Contributor

The packet loss test is sending 1000 messages and expecting about 25% of them to be dropped. Issue is, these 1000 messages will get batched together into roughly a dozen packets on the wire. By chance, the UTP simulator stage has bug where it always uses the same seed for its RNG. In UTP 1.X, this seed led to 4 packets being dropped, which was enough to get the test to pass. In UTP 2.0, this seed is only getting 2 packets to be dropped (because the call patterns to the RNG are different) and this causes the test to fail.

UTP is getting fixed to not always use the same seed by default, so soon this test will become unstable since it will be at the mercy of the RNG. But UTP does support fixing the seed for just these kinds of scenarios. This PR exposes this functionality to NGO (internal API only) and makes use of it in the packet loss test. The size of the messages being sent is also increased to avoid only sending a dozen packets on the wire.

Changelog

N/A

Testing and Documentation

  • No tests have been added.
  • No documentation changes or additions were necessary.

@simon-lemay-unity simon-lemay-unity requested review from a team as code owners August 31, 2022 21:28
@simon-lemay-unity simon-lemay-unity changed the title fix: Rework packet loss metric tests to work with UTP 2.0 fix: Rework packet loss metric tests to work with UTP 2.0 [MTT-4535] Aug 31, 2022
protected override void OnServerAndClientsCreated()
{
var clientTransport = (UnityTransport)m_ClientNetworkManagers[0].NetworkConfig.NetworkTransport;
clientTransport.DebugSimulatorRandomSeed = 4; // Determined through trial and error.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uhhh can you explain this trial and error a little bit

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, sorry - I should have read the PR description

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might be worth including a comment about why the seed is important, future updates to UTP could change the call pattern to the RNG again and break this test and some poor developer is going to have to retrace your steps

@simon-lemay-unity simon-lemay-unity merged commit 8a34a1c into develop Sep 6, 2022
@simon-lemay-unity simon-lemay-unity deleted the fix/packet-loss-test branch September 6, 2022 17:56
jakobbbb pushed a commit to GooseGirlGames/com.unity.netcode.gameobjects that referenced this pull request Feb 22, 2023
…nity-Technologies#2174)

* Allow fixing the simulator RNG seed

* Fix packet loss test for UTP 2.0

* Add comment about random seed in packet loss test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants